/*
 * All rights Reserved, Designed By www.goldbeacon.cn
 * @Title:  demo
 * @Package cn.goldbeacon.demo.common.config
 * @author: zoujie
 * @date:   2021/7/2313:47
 * @version V1.0
 * Copyright © 2021 www.goldbeacon.cn. All Rights Reserved.
 * 注意：本内容仅限于湖南金烽信息科技有限公司内部传阅，禁止外泄以及用于其他的商业目
 */
package com.chenzhengrong.demospringboot.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author zoujie
 * @title: SwaggerConfig
 * @description: Swagger配置类
 * @date 2021/7/2313:47
 */
@Configuration // 添加spring注解
@EnableSwagger2 // 添加开启swsagger注解
public class SwaggerConfig {

    /**
    * @description: 自定义 Docket
    * @return springfox.documentation.spring.web.plugins.Docket
    * @author zoujie
    * @date 2021/7/23 13:50
    */
    @Bean
    public Docket customDocket() {

        return new Docket(DocumentationType.SWAGGER_2) //swagger版本
                .pathMapping("/")
                .select()
                //扫描那些controller
                .apis(RequestHandlerSelectors.basePackage("com.chenzhengrong.demospringboot.controlloer"))
                .paths(PathSelectors.any())
                .build()
                .apiInfo(apiInfo());
    }

    /**
    * @description: api信息
    * @return springfox.documentation.service.ApiInfo
    * @author zoujie
    * @date 2021/7/23 13:51
    */
    private ApiInfo apiInfo() {
        /** name:开发者姓名， url:开发者网址，email:开发者邮箱，title：标题，description：文档接口的描述，version：版本号 */
        Contact contact = new Contact("czr", "http://goldbeacon.cn/", "business@goldbeacon.cn");
        return new ApiInfoBuilder()
                .title("czrAPI接口")
                .description("API接口的描述")
                .contact(contact)
                .version("1.0.0")
                .build();
    }
}
